#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 4e5 + 10;

int h, w;
string s[N], cag[N];
unordered_map<string, int> mp;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> h >> w;
    for(int i = 1; i <= h; i ++){
        cin >> s[i];
    }

    for(int i = 0; i < w; i ++){
        string temp = "";
        for(int j = 1; j <= h; j ++){
            temp += s[j][i];
        }
        
        if(mp.count(temp)){
            mp[temp] ++;
        }else{
            mp[temp] = 1;
        }
    }

    for(int i = 1; i <= h; i ++){
        cin >> s[i];
    }

    for(int i = 0; i < w; i ++){
        string temp = "";
        for(int j = 1; j <= h; j ++){
            temp += s[j][i];
        }

        if(mp.count(temp) && mp[temp] >= 1){
            mp[temp] --;
        }else{
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
    return 0;
}